<?php

include_once( dirname(__FILE__).'/compat.joomla1.5.php' );

if(!defined( '_JLEGACY' ))
{
 $GLOBALS['path'] = $mosConfig_live_site."/components/com_medialibrary/images/";
}
else 
{
$GLOBALS['path'] = $mosConfig_live_site."/administrator/components/com_medialibrary/images/";
}
$path = $GLOBALS['path'];
class DMInstallHelper
{ 
    function getComponentId()
    {
        static $id;

        if(!$id)
        {
            global $database;
            $database->setQuery("SELECT id FROM #__components WHERE name= 'Book Library'");
            $id =$database->loadResult();
        }
        return $id;
    }

   
    function setAdminMenuImages(){
      global $database,$path;

        $id = DMInstallHelper::getComponentId();

        // Main mennu
        $database->setQuery("UPDATE #__components SET admin_menu_img = '".$path."dm_component_16.png' WHERE id=$id");
        $database->query();

        // Submenus
        $submenus = array();
        $submenus[] = array( 'image' => $path.'dm_edit_16.png', 'name'=>'Books' );
        $submenus[] = array( 'image' => $path.'dm_edit_16.png', 'name'=>'Music' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Categories' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Reviews' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Suggestions' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Lend Requests' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Import/Export' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Settings Frontend' );
        $submenus[] = array( 'image' => $path.'dm_component_16.png', 'name'=>'Settings Backend' );
        $submenus[] = array( 'image' => $path.'dm_credits_16.png', 'name'=>'About' );
       
        foreach( $submenus as $submenu )
        {

          $database->setQuery("UPDATE #__components SET admin_menu_img = '".$submenu['image']."'"
                              . "\n WHERE parent=$id AND name = '".$submenu['name']."';");
          $database->query();
        }

    }
}

?>
